<#assign contextPath=springMacroRequestContext.getContextPath() />
<header class="navbar-wrapper">
	<div class="navbar navbar-fixed-top">
		<div class="container-fluid cl ">
         <span class="logo  f-l mr-10 hidden-xs">
			<img src="${contextPath}/resources/images/czshop_admin.png" width="220px" style="align:center;"></span>
			<nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
				<ul class="cl">
					<li>${user.employee.name}</li>
					<li class="dropDown dropDown_hover">
						<a href="#" class="dropDown_A">${user.loginName} <i class="Hui-iconfont">&#xe6d5;</i></a>
						<ul class="dropDown-menu menu radius box-shadow">
							<li><a href="javascript:void(0)" onclick="openModifyPwdLayer();">修改密码</a></li>
							<li><a href="${contextPath}/login/out">退出</a></li>
						</ul>
					</li>
					<li id="Hui-msg" >
					<#if monitorOrderCount?? && (monitorOrderCount  &gt; 0) >
					<a  data-href="${contextPath}/monitor/query_monitor_order_list"  data-title="异常兑换列表"
					 onclick="Hui_admin_tab(this)" href="javascript:;" id="yichang"
					data-container="body" data-toggle="popover" data-placement="bottom"
					 data-content="你收到<font color='red'>${monitorOrderCount!'0'}</font>个异常兑换订单，请处理" 
					 data-html="true"  data-trigger="hover click" >
					<span class="badge badge-danger" >${monitorOrderCount!'0'}</span>
					<i class="Hui-iconfont" style="font-size:18px">&#xe68a;</i>
					</a> 
					<#else>
					<a href="#"  id="yichang" >
					<i class="Hui-iconfont" style="font-size:18px">&#xe68a;</i>
					</a> 	
					</#if>
				
					</li>
				</ul>
			</nav>
		</div>
	</div>
	<div id="modifyPwdLayer" style="display: none;">
		<div style="padding: 15px;">
			<table class="table">
		  		<tr>
		  			<td>当前密码：</td>
		  			<td><input type="password" maxlength="20" class="input-text radius" style="width: 250px;" id="curPwd"/></td>
		  		</tr>
		  		<tr>
		  			<td>新密码：</td>
		  			<td><input type="password" maxlength="20" class="input-text radius" style="width: 250px;" id="newPwd"/></td>
		  		</tr>
		  		<tr>
		  			<td>确认新密码：</td>
		  			<td><input type="password" maxlength="20" class="input-text radius" style="width: 250px;" id="conNewPwd"/></td>
		  		</tr>
		  		<tr>
		  			<td colspan="2" style="text-align: center;">
		  				<input type="button" class="btn btn-success radius" value="确定 " onclick="confirmModifyPwd();"/>
		  				<input type="button" class="btn btn-warning radius" value="关闭 " onclick="closeModifyPwdLayer();"/>
		  			</td>
		  		</tr>
			</table>
		</div>
	</div>
	<script>
	window.onload=function(){
		$('#yichang').popover('show');
		$('body').on('click', function(event) {  
			$('#yichang').popover('hide');
		});
	}
	
	var modifyPwdLayerIndex;
	function openModifyPwdLayer(){
		clearInput();
		modifyPwdLayerIndex = layer.open({
			type: 1,
			title: "修改密码",
			content: $("#modifyPwdLayer"),
			area:["420px", "265px"]
		});
	}
	
	function confirmModifyPwd() {
		var curPwd = $("#curPwd").val();
		if(curPwd == "") {
			layer.alert("当前密码不能为空！");
			return false;
		}
		var newPwd = $("#newPwd").val();
		if(newPwd == "") {
			layer.alert("新密码不能为空！");
			return false;
		}
		if(curPwd == newPwd) {
			layer.alert("当前密码与新密码不能相同！");
			return false;
		}
		if(newPwd.length > 20 || newPwd.length < 8) {
			layer.alert("登录密码只能为8-20位！");
			return false;
		}
		var conNewPwd = $("#conNewPwd").val();
		if(conNewPwd == "") {
			layer.alert("确认新密码不能为空！");
			return false;
		}
		if(newPwd != conNewPwd) {
			layer.alert("新密码和确认新密码不一致！");
			return false;
		}
		
		$.ajax({
			url: "${contextPath}/user/modifyUserPwd",
		   	type: "post",
		   	dataType: "text",
		   	data: {
		   		"curPwd": curPwd,
		   		"newPwd": newPwd,
		   		"conNewPwd": conNewPwd
		   	},
		   	success: function(msg) {
				if(msg != "success") {
					layer.alert(msg);
				} else {
					layer.msg("修改成功", {
						icon: 1,
						time: 500
					}, function(){
						closeModifyPwdLayer();
					});   
				}
			},
			error: function() {
				layer.alert("修改失败");
			}
		});
	}
	
	function clearInput() {
		$("#curPwd").val("");
		$("#newPwd").val("");
		$("#conNewPwd").val("");
	}
	
	function closeModifyPwdLayer() {
		layer.close(modifyPwdLayerIndex);
	}
	</script>
</header>